
angular.module('QualityJudge')

.factory('QualityJudgeHttpUtil', ['User', 'Device', 'Http', 'QUALITYJUDGECONSTANTS', 
    function (User, Device, Http, QUALITYJUDGECONSTANTS) {
        var o = {};

        o.queryMasters = function () {
            return Http.post({
                url: QUALITYJUDGECONSTANTS.queryBadMastersURL
            });
        };
        o.decideScanCode = function (barcode) {
            return Http.post({
                url: QUALITYJUDGECONSTANTS.decideScanCodeURL,
                data: {
                    Parameter: {
                        Barcode: barcode
                    }
                }
            });
        };
        o.doJudge = function (barcode, qcStatus) {
            return Http.post({
                url: QUALITYJUDGECONSTANTS.doJudgeURL,
                data: {
                    Parameter: {
                        Barcode: barcode,
                        TerminalUniqueID: Device.getUUID(),
                        UserID: User.get('_id'),
                        QCStatus: qcStatus
                    }
                }
            });
        };
        o.getProductFlow = function (barcode) {
            return Http.post({
                url: QUALITYJUDGECONSTANTS.getProductFlowURL,
                data: {
                    Parameter: {
                        Barcode: barcode
                    }
                }
            });
        };

        return o;
    }
]);